using System.ComponentModel.DataAnnotations;
using FytSoa.Common.Enum;
using SqlSugar;

namespace FytSoa.Domain.Erp;

/// <summary>
/// erp_流程管理
/// </summary>
[SugarTable("erp_flow")]
public class ErpFlow:Entity
{
    /// <summary>
    /// 自定义表单编号
    /// </summary>
    public long FormId { get; set; } = 0;
    
    /// <summary>
    /// 编号
    /// </summary>
    [Required]
    [StringLength(40)]
    public string Number { get; set; }

    /// <summary>
    /// 流程名称
    /// </summary>
    [Required]
    [StringLength(50)]
    public string Name { get; set; }

    /// <summary>
    /// 审批流程类型
    /// </summary>
    public string FlowType { get; set; }
    
    /// <summary>
    /// 图标
    /// </summary>
    [StringLength(30)]
    public string Icon { get; set; }

    /// <summary>
    /// 流程节点
    /// </summary>
    [Required]
    [SugarColumn(IsJson = true)]
    public List<ErpFlowNodes> Nodes { get; set; } = new();

    /// <summary>
    /// 状态
    /// </summary>
    [Required]
    public bool Status { get; set; } = true;
    
    /// <summary>
    /// 支持申请
    /// </summary>
    [Required]
    public bool IsApply { get; set; } = false;
    
    /// <summary>
    /// 行政流程枚举编码
    /// </summary>
    public FlowTypeEnum TypeNumber { get; set; } = 0;

    /// <summary>
    /// 创建人
    /// </summary>
    public string CreateUser { get; set; }

    /// <summary>
    /// 创建时间
    /// </summary>
    [Required]
    public DateTime CreateTime { get; set; } = DateTime.Now;

    /// <summary>
    /// 更新人
    /// </summary>
    public string UpdateUser { get; set; }

    /// <summary>
    /// 更新时间
    /// </summary>
    public DateTime? UpdateTime { get; set; }

    /// <summary>
    /// 流程节点
    /// </summary>
    public class ErpFlowNodes
    {
        /// <summary>
        /// 编号
        /// </summary>
        public int Number { get; set; } = 1;
        
        /// <summary>
        /// 审批人
        /// </summary>
        public long EmployeeId { get; set; } = 0;
    }
}